<template>
  <div class="detail">
    <Row>
       <Filed :span="6" :name="l('tableDescription')">{{
        entity.tableDescription
      }}</Filed>
      <Filed :span="6" :name="l('entityName')">{{ entity.entityName }}</Filed>
      <Filed :span="6" :name="l('dbTableName')">{{
        entity.dbTableName
      }}</Filed>
      <Filed :span="6" :name="l('base')">{{ entity.base }}</Filed>
      <Filed :span="6" :name="l('dbFullName')">{{ entity.dbFullName }}</Filed>
       <Filed :span="6" :name="l('status')">{{ entity.status }}</Filed>
      <Filed :span="12" :name="l('methods')">{{ entity.methods }}</Filed>
      <!-- <Filed :span="6" :name="l('nameRule')">{{ entity.nameRule }}</Filed> -->
     
      <Filed :span="6" :name="$t('creationTime')">{{
        entity.creationTime
      }}</Filed>
      <Filed :span="6" :name="$t('creatorUserId')">{{
        entity.creatorUserId
      }}</Filed>
      <Filed :span="6" :name="$t('lastModificationTime')">{{
        entity.lastModificationTime
      }}</Filed>
      <Filed :span="6" :name="$t('lastModifierUserId')">{{
        entity.lastModifierUserId
      }}</Filed>
     
    </Row>
    <Table :columns="columns" border :data="entity.columns"></Table>
  </div>
</template>
<script>
import Api from "./api";
export default {
  name: "Add",
  data() {
    return {
      entity: {},
      columns: [
        {
          type: "index",
          width: 60,
          align: "center",
        },
        {
          title: "数据库设置",
          children: [
            {
              key: "link",
              title: "外键",
              align: "center",
              width: 70,
            },
            {
              key: "isPrimarykey",
              title: "主键",
              align: "center",
              width: 70,
            },
            {
              key: "columnDescription",
              title: "名称",
              align: "left",
            },
            {
              key: "dbColumnName",
              title: "字段",
              align: "left",
              easy: true,
              hide: true,

              width: 200,
            },
            {
              key: "inputType",
              title: "设置",
              align: "left",

              width: 150,
            },
            {
              key: "dataType",
              title: "数据类型",
              align: "left",
              hide: true,
              width: 150,
            },
            {
              key: "length",
              title: "长度",
              align: "left",
              hide: true,
              width: 100,
            },
            {
              key: "decimalDigits",
              title: "小数位数",
              align: "left",
              width: 100,
              hide: true,
            },
            {
              key: "defaultValue",
              title: "默认值",
              align: "left",
              width: 100,
              hide: true,
            },
            {
              key: "isNullable",
              title: "可空",
              align: "center",
              width: 70,
            },
          ],
        },
        {
          title: "业务设置",
          hide: true,
          children: [
            {
              key: "propertyName",
              title: "属性名",
              align: "left",
              hide: true,
              width: 100,
            },
            {
              key: "propertyType",
              title: "属性类型",
              align: "left",
              width: 100,
              hide: true,
            },
            {
              key: "code",
              title: "数据编码",
              align: "left",
            },
            {
              key: "unit",
              title: "单位",
              align: "left",

              width: 100,
            },
            {
              key: "single",
              title: "唯一",
              align: "left",

              width: 70,
            },
          ],
        },
      ],
    };
  },
  props: {
    eid: String,
  },
  mounted() {
    if (this.eid) {
      this.load(this.eid);
    }
  },
  methods: {
    load(v) {
      Api.get({ id: v }).then((r) => {
        this.entity = r.result;
        this.$emit("on-load");
      });
    },
    handleClose() {
      this.$emit("on-close");
    },
    l(key) {
      key = "DbEntityDefined" + "." + key;
      return this.$t(key);
    },
  },
  watch: {
    eid(v) {
      if (v) {
        this.load(v);
      }
    },
  },
};
</script>